package l1j.server.server.model.damage;

import static l1j.server.server.model.skill.L1SkillId.FINAL_BURN;
import static l1j.server.server.model.skill.L1SkillId.ILLUSION_AVATAR;
import static l1j.server.server.model.skill.L1SkillId.JOY_OF_PAIN;
import l1j.server.server.model.Instance.L1NpcInstance;
import l1j.server.server.templates.L1Skills;

public class L1NpcMagic {
	private L1NpcInstance _attacker;

	private L1Dmg _dmg;

	public L1NpcMagic(L1NpcInstance attacker, L1Dmg dmg) {
		_attacker = attacker;
		_dmg = dmg;
	}

	public void calcNpcDmg() {
		L1Skills skill = _attacker.getCurrentSkill();
		int skillId = skill.getId();

		// 疼痛的歡愉傷害：(最大血量 - 目前血量 /5)
		if (skillId == JOY_OF_PAIN) {
			_dmg.add(_attacker.getMaxHp() - _attacker.getCurrentHp());
			_dmg.div(5);
		} else {
			if (skillId == FINAL_BURN) {
				_dmg.add(_attacker.getCurrentMp());
			} else {
				_dmg.add(skill.calcMagicDiceDamage());
				_dmg.mul(_attacker.calcMagicCoef());

				if (_attacker.hasSkillEffect(ILLUSION_AVATAR)) {
					_dmg.add(10);
				}
				_dmg.mul(_attacker.getLeverage() / 10.0);
			}
		}
	}

}
